home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / util / misc / MUser17src.lha / MultiUser / src / Library / multiuser.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-07  |  16.9 KB  |  514 lines

  1. #ifndef LIBRARIES_MULTIUSER_H
  2. #define LIBRARIES_MULTIUSER_H
  3. /*
  4. **      $VER: multiuser.h 39.13 (2.3.94)
  5. **      MultiUser Release 1.7
  6. **
  7. **      multiuser.library definitions
  8. **
  9. **      (C) Copyright 1993-1994 Geert Uytterhoeven
  10. **          All Rights Reserved
  11. */
  12.  
  13. #ifndef EXEC_TYPES_H
  14. #include <exec/types.h>
  15. #endif  /* EXEC_TYPES_H */
  16.  
  17. #ifndef EXEC_LISTS_H
  18. #include <exec/lists.h>
  19. #endif  /* EXEC_LISTS_H */
  20.  
  21. #ifndef EXEC_LIBRARIES_H
  22. #include <exec/libraries.h>
  23. #endif  /* EXEC_LIBRARIES_H */
  24.  
  25. #ifndef EXEC_PORTS_H
  26. #include <exec/ports.h>
  27. #endif  /* EXEC_PORTS_H */
  28.  
  29. #ifndef LIBRARIES_DOS_H
  30. #include <libraries/dos.h>
  31. #endif  /* LIBRARIES_DOS_H */
  32.  
  33. #ifndef UTILITY_TAGITEM_H
  34. #include <utility/tagitem.h>
  35. #endif  /* UTILITY_TAGITEM_H */
  36.  
  37.  
  38. #define MULTIUSERNAME         "multiuser.library"
  39. #define MULTIUSERVERSION      (39)
  40.  
  41.  
  42.    /*
  43.     *    Reserved users/groups
  44.     *
  45.     *    WARNING: a uid may NOT be zero, a gid may be zero
  46.     */
  47.  
  48. #define muOWNER_NOBODY  (0x00000000)   /* no rights */
  49. #define muOWNER_SYSTEM  (0xffffffff)   /* always owner */
  50.  
  51. #define muMASK_UID      (0xffff0000)   /* Mask for uid bits */
  52. #define muMASK_GID      (0x0000ffff)   /* Mask for gid bits */
  53.  
  54. #define muROOT_UID      (0xffff)       /* super user uid */
  55. #define muROOT_GID      (0xffff)       /* super user gid */
  56.  
  57. #define muNOBODY_UID    (0x0000)       /* nobody uid */
  58.  
  59. #define muUSERIDSIZE    (32)           /* Maximum size for a User ID */
  60. #define muGROUPIDSIZE   (32)           /* Maximum size for a Group ID */
  61. #define muPASSWORDSIZE  (32)           /* Maximum size for a Password */
  62. #define muUSERNAMESIZE  (220)          /* Maximum size for a User Name */
  63. #define muGROUPNAMESIZE (220)          /* Maximum size for a Group Name */
  64. #define muHOMEDIRSIZE   (256)          /* Maximum size for a Home Directory */
  65. #define muSHELLSIZE     (256)          /* Maximum size for a Shell */
  66.  
  67.  
  68.    /*
  69.     *    Password File
  70.     *
  71.     *
  72.     *    For each user, the Password File must contain a line like this:
  73.     *
  74.     *    <UserID>|<Password>|<uid>|<gid>|<UserName>|<HomeDir>|<Shell>
  75.     *
  76.     *    with:
  77.     *
  78.     *       <UserID>    User Login ID (max. muUSERIDSIZE-1 characters)
  79.     *       <PassKey>   Encrypted Password
  80.     *       <uid>       User Number (1 - 65535)
  81.     *       <gid>       Primary Group Number (0 - 65535)
  82.     *       <UserName>  Full User Name (max. muUSERNAMESIZE-1 characters)
  83.     *       <HomeDir>   Home directory (max. muHOMEDIRSIZE-1 characters)
  84.     *       <Shell>     Default Shell (max. muSHELLSIZE-1 characters)
  85.     *                   (not used yet, AS225 compatibility)
  86.     */
  87.  
  88. #define muPasswd_FileName     "passwd"  /* for AS225 compatibility */
  89.  
  90.  
  91.    /*
  92.     *    Group File
  93.     *
  94.     *
  95.     *    This file gives more information about the groups and defines
  96.     *    the secondary groups (other than the primary group) a user
  97.     *    belongs to. It exists out of two parts, separated by a blank line.
  98.     *
  99.     *    The first part contains lines with the format:
  100.     *
  101.     *    <GroupID>|<gid>|<MgrUid>|<GroupName>
  102.     *
  103.     *    with:
  104.     *
  105.     *       <GroupID>   Group short ID (max. muGROUPIDSIZE-1 characters)
  106.     *       <gid>       Group Number (0 - 65535)
  107.     *       <MgrUid>    User Number of this group's manager, 0 for no
  108.     *                   manager. A group's manager must not belong to the
  109.     *                   group.
  110.     *       <GroupName> Full Group Name (max. muGROUPNAMESIZE-1 characters)
  111.     *
  112.     *    NOTE: Not every group must have a line in this file, but at least
  113.     *          one group must have one.
  114.     *
  115.     *
  116.     *    The seconds part contains lines with the format:
  117.     *
  118.     *    <uid>:<gid>[,<gid>...]
  119.     *
  120.     *    with:
  121.     *
  122.     *       <uid>       User Number (1-65535)
  123.     *       <gid>       Group Number (0 - 65535)
  124.     *
  125.     *    If you think you'll exceed the maximum line length (circa 1K),
  126.     *    you may use more than one line per user.
  127.     */
  128.  
  129. #define muGroup_FileName      "MultiUser.group"
  130.  
  131.  
  132.    /*
  133.     *    Configuration File
  134.     *
  135.     *
  136.     *    This file contains lines with options in the form <OPT>=<val>.
  137.     *    0 is used for OFF, 1 for ON.
  138.     *    Defaults to the values between square brackets.
  139.     *
  140.     *    LIMITDOSSETPROTECTION   dos.library/SetProtection() cannot change
  141.     *                            protection bits for GROUP and OTHER [1]
  142.     *    PROFILE                 execute the Profile if it exists [1]
  143.     *    LASTLOGINREQ            display the Lastlogin requester [1]
  144.     *    LOGSTARTUP              log startup [0]
  145.     *    LOGLOGIN                log successful logins [0]
  146.     *    LOGLOGINFAIL            log failed logins [0]
  147.     *    LOGPASSWD               log successful password changes [0]
  148.     *    LOGPASSWDFAIL           log failed password changes [0]
  149.     *    LOGCHECKPASSWD          log successful password checks [0]
  150.     *    LOGCHECKPASSWDFAIL      log failed password checks [0]
  151.     *    PASSWDUIDLEVEL          users with a uid greather than or equal to
  152.     *                            <val> can change their passwords [0]
  153.     *    PASSWDGIDLEVEL          users with a gid greather than or equal to
  154.     *                            <val> can change their passwords [0]
  155.     *
  156.     *    NOTE: if a user has a uid less than the PASSWDUIDLEVEL AND a gid
  157.     *          less than PASSWDGIDLEVEL he/she is NOT allowed to change
  158.     *          his/her password!
  159.     */
  160.  
  161. #define muConfig_FileName     "MultiUser.config"
  162.  
  163.  
  164.    /*
  165.     *    Log File
  166.     */
  167.  
  168. #define muLog_FileName        "MultiUser.log"
  169.  
  170.  
  171.    /*
  172.     *    Lastlogin File
  173.     */
  174.  
  175. #define muLastLogin_FileName  ".lastlogin"
  176.  
  177.  
  178.    /*
  179.     *    Profile
  180.     */
  181.  
  182. #define muProfile_FileName    ".profile"
  183.  
  184.  
  185.    /*
  186.     *    Plan file
  187.     */
  188.  
  189. #define muPlan_FileName       ".plan"
  190.  
  191.  
  192.    /*
  193.     *    Key File
  194.     *
  195.     *
  196.     *    This file must be present in the root directory of every volume
  197.     *    that uses the MultiUserFileSystem. It must contain 3 lines:
  198.     *
  199.     *       - a pseudo random ASCII key (max. 1023 characters).
  200.     *       - the directory of the password file, if located on this volume,
  201.     *         otherwise an empty line (no spaces!).
  202.     *           e.g. ":MultiUser"
  203.     *           e.g. ":inet/db" for AS225 compatibility
  204.     *       - the directory of the configuration file, if located on this
  205.     *         volume, otherwise an empty line (no spaces!).
  206.     *           e.g. ":MultiUser"
  207.     *
  208.     *    If there is ANY inconsistency the system will refuse to work!!
  209.     */
  210.  
  211. #define muKey_FileName        ":.MultiUser.keyfile"
  212.  
  213.  
  214.    /*
  215.     *    Tags for muLogoutA()
  216.     *             muLoginA()
  217.     *             muSetDefProtectionA()
  218.     */
  219.  
  220. #define muT_Input          (TAG_USER+1)   /* filehandle - default is Input() */
  221. #define muT_Output         (TAG_USER+2)   /* filehandle - default is Output() */
  222. #define muT_Graphical      (TAG_USER+3)   /* boolean - default is FALSE */
  223. #define muT_PubScrName     (TAG_USER+4)   /* name of public screen */
  224. #define muT_Task           (TAG_USER+5)   /* task (NOT the name!!) */
  225. #define muT_Own            (TAG_USER+6)   /* make a task owned by this user */
  226. #define muT_Global         (TAG_USER+7)   /* change it for all tasks on the */
  227.                                           /* same level as this one */
  228. #define muT_Quiet          (TAG_USER+8)   /* for muLogoutA(), don't give a */
  229.                                           /* login prompt, simply logout */
  230. #define muT_UserID         (TAG_USER+9)   /* UserID for muLoginA() */
  231. #define muT_Password       (TAG_USER+10)  /* Password for muLoginA(), must */
  232.                                           /* be combined with muT_UserID!! */
  233. #define muT_DefProtection  (TAG_USER+11)  /* Default protection bits */
  234.                                           /* default is RWED GROUP R OTHER R */
  235. #define muT_All            (TAG_USER+12)  /* for muLogoutA(), logout until */
  236.                                           /* user stack is empty */
  237. #define muT_NoLog          (TAG_USER+13)  /* for muLoginA(), only root */
  238.  
  239.  
  240.    /*
  241.     *    Public User Information Structure
  242.     *
  243.     *
  244.     *    For future compatibility, you should ALWAYS use muAllocUserInfo()
  245.     *    to allocate this structure. NEVER do it by yourself!!
  246.     */
  247.  
  248. struct muUserInfo {
  249.    char UserID[muUSERIDSIZE];
  250.    UWORD uid;
  251.    UWORD gid;
  252.    char UserName[muUSERNAMESIZE];
  253.    char HomeDir[muHOMEDIRSIZE];
  254.    UWORD NumSecGroups;              /* Number of Secondary Groups this */
  255.                                     /* user belongs to */
  256.    UWORD *SecGroups;                /* Points to an array of NumSecGroups */
  257.                                     /* Secondary Group Numbers */
  258.    char Shell[muSHELLSIZE];
  259. };
  260.  
  261.  
  262.    /*
  263.     *    Public Group Information Structure
  264.     *
  265.     *
  266.     *    For future compatibility, you should ALWAYS use muAllocGroupInfo()
  267.     *    to allocate this structure. NEVER do it by yourself!!
  268.     */
  269.  
  270. struct muGroupInfo {
  271.    char GroupID[muGROUPIDSIZE];
  272.    UWORD gid;
  273.    UWORD MgrUid;                    /* Manager of this group */
  274.    char GroupName[muGROUPNAMESIZE];
  275. };
  276.  
  277.  
  278.    /*
  279.     *    KeyTypes for muGetUserInfo()
  280.     *                 muGetGroupInfo()
  281.     */
  282.  
  283. #define muKeyType_First          (0)
  284. #define muKeyType_Next           (1)
  285. #define muKeyType_gid            (4)
  286.  
  287.    /*
  288.     *    KeyTypes for muGetUserInfo() only
  289.     */
  290.  
  291. #define muKeyType_UserID         (2)   /* Case-sensitive */
  292. #define muKeyType_uid            (3)
  293. #define muKeyType_gidNext        (5)
  294. #define muKeyType_UserName       (6)   /* Case-insensitive */
  295. #define muKeyType_WUserID        (7)   /* Case-insensitive, wild cards allowed */
  296. #define muKeyType_WUserName      (8)   /* Case-insensitive, wild cards allowed */
  297. #define muKeyType_WUserIDNext    (9)
  298. #define muKeyType_WUserNameNext  (10)
  299.  
  300.    /*
  301.     *    KeyTypes for muGetGroupInfo() only
  302.     */
  303.  
  304. #define muKeyType_GroupID        (11)  /* Case-sensitive */
  305. #define muKeyType_WGroupID       (12)  /* Case-insensitive, wild cards allowed */
  306. #define muKeyType_WGroupIDNext   (13)
  307. #define muKeyType_GroupName      (14)  /* Case-insensitive */
  308. #define muKeyType_WGroupName     (15)  /* Case-insensitive, wild cards allowed */
  309. #define muKeyType_WGroupNameNext (16)
  310. #define muKeyType_MgrUid         (17)
  311. #define muKeyType_MgrUidNext     (18)
  312.  
  313.  
  314.    /*
  315.     *    Extended Owner Information Structure
  316.     *
  317.     *
  318.     *    A pointer to this structure is returned by muGetTaskExtOwner().
  319.     *    You MUST use muFreeExtOwner() to deallocate it!!
  320.     */
  321.  
  322. struct muExtOwner {
  323.    UWORD uid;
  324.    UWORD gid;
  325.    UWORD NumSecGroups;              /* Number of Secondary Groups this */
  326.                                     /* user belongs too. */
  327. };
  328.  
  329.    /* NOTE: This structure is followed by a UWORD array containing
  330.     *       the Secondary Group Numbers
  331.     *       Use the following macro to access these group numbers,
  332.     *       e.g. sgid = muSecGroups(extowner)[i];
  333.     *
  334.     *       Do not use this macro on a NULL pointer!!
  335.     */
  336.  
  337. #define muSecGroups(x) ((UWORD *)((UBYTE *)x+sizeof(struct muExtOwner)))
  338.  
  339.  
  340.    /*
  341.     *    Macro to convert an Extended Owner Information Structure to a ULONG
  342.     *    (cfr. muGetTaskOwner())
  343.     */
  344.  
  345. #define muExtOwner2ULONG(x) ((ULONG)(x ? (x)->uid<<16|(x)->gid : muOWNER_NOBODY))
  346.  
  347.  
  348.    /*
  349.     *    Packet types (see also <dos/dosextens.h> :-)
  350.     */
  351.  
  352. /* #define ACTION_SET_OWNER        1036 */
  353.  
  354.  
  355.    /*
  356.     *    Protection bits (see also <dos/dos.h> :-)
  357.     */
  358.  
  359. #define muFIBB_SET_UID        (31)  /* Change owner during execution */
  360.  
  361. /* FIBB are bit definitions, FIBF are field definitions */
  362. /* Regular RWED bits are 0 == allowed. */
  363. /* NOTE: GRP and OTR RWED permissions are 0 == not allowed! */
  364.  
  365. /* #define FIBB_OTR_READ      15   Other: file is readable */
  366. /* #define FIBB_OTR_WRITE     14   Other: file is writable */
  367. /* #define FIBB_OTR_EXECUTE   13   Other: file is executable */
  368. /* #define FIBB_OTR_DELETE    12   Other: prevent file from being deleted */
  369. /* #define FIBB_GRP_READ      11   Group: file is readable */
  370. /* #define FIBB_GRP_WRITE     10   Group: file is writable */
  371. /* #define FIBB_GRP_EXECUTE   9    Group: file is executable */
  372. /* #define FIBB_GRP_DELETE    8    Group: prevent file from being deleted */
  373.  
  374. /* #define FIBB_SCRIPT        6    program is a script (execute) file */
  375. /* #define FIBB_PURE          5    program is reentrant and rexecutable */
  376. /* #define FIBB_ARCHIVE       4    cleared whenever file is changed */
  377. /* #define FIBB_READ          3    ignored by old filesystem */
  378. /* #define FIBB_WRITE         2    ignored by old filesystem */
  379. /* #define FIBB_EXECUTE       1    ignored by system, used by Shell */
  380. /* #define FIBB_DELETE        0    prevent file from being deleted */
  381.  
  382. #define muFIBF_SET_UID        (1<<muFIBB_SET_UID)
  383.  
  384. /* #define FIBF_OTR_READ      (1<<FIBB_OTR_READ) */
  385. /* #define FIBF_OTR_WRITE     (1<<FIBB_OTR_WRITE) */
  386. /* #define FIBF_OTR_EXECUTE   (1<<FIBB_OTR_EXECUTE) */
  387. /* #define FIBF_OTR_DELETE    (1<<FIBB_OTR_DELETE) */
  388. /* #define FIBF_GRP_READ      (1<<FIBB_GRP_READ) */
  389. /* #define FIBF_GRP_WRITE     (1<<FIBB_GRP_WRITE) */
  390. /* #define FIBF_GRP_EXECUTE   (1<<FIBB_GRP_EXECUTE) */
  391. /* #define FIBF_GRP_DELETE    (1<<FIBB_GRP_DELETE) */
  392.  
  393. /* #define FIBF_SCRIPT        (1<<FIBB_SCRIPT) */
  394. /* #define FIBF_PURE          (1<<FIBB_PURE) */
  395. /* #define FIBF_ARCHIVE       (1<<FIBB_ARCHIVE) */
  396. /* #define FIBF_READ          (1<<FIBB_READ) */
  397. /* #define FIBF_WRITE         (1<<FIBB_WRITE) */
  398. /* #define FIBF_EXECUTE       (1<<FIBB_EXECUTE) */
  399. /* #define FIBF_DELETE        (1<<FIBB_DELETE) */
  400.  
  401.  
  402.    /*
  403.     *    Default Protection Bits
  404.     */
  405.  
  406. #define DEFPROTECTION (FIBF_OTR_READ | FIBF_GRP_READ)
  407.  
  408.  
  409.    /*
  410.     *    Relations returned by muGetRelationshipA()
  411.     */
  412.  
  413. #define muRelB_ROOT_UID    (0)   /* User == super user */
  414. #define muRelB_ROOT_GID    (1)   /* User belongs to the super user group */
  415. #define muRelB_NOBODY      (2)   /* User == nobody */
  416. #define muRelB_UID_MATCH   (3)   /* User == owner */
  417. #define muRelB_GID_MATCH   (4)   /* User belongs to owner group */
  418. #define muRelB_PRIM_GID    (5)   /* User's primary group == owner group */
  419. #define muRelB_NO_OWNER    (6)   /* Owner == nobody */
  420.  
  421. #define muRelF_ROOT_UID    (1<<muRelB_ROOT_UID)
  422. #define muRelF_ROOT_GID    (1<<muRelB_ROOT_GID)
  423. #define muRelF_NOBODY      (1<<muRelB_NOBODY)
  424. #define muRelF_UID_MATCH   (1<<muRelB_UID_MATCH)
  425. #define muRelF_GID_MATCH   (1<<muRelB_GID_MATCH)
  426. #define muRelF_PRIM_GID    (1<<muRelB_PRIM_GID)
  427. #define muRelF_NO_OWNER    (1<<muRelB_NO_OWNER)
  428.  
  429.  
  430.    /*
  431.     *    Monitor Structure
  432.     *
  433.     *
  434.     *    The use of this structure is restricted to root.
  435.     *    Do not modify or reuse this structure while it is active!
  436.     */
  437.  
  438. struct muMonitor {
  439.    struct MinNode Node;
  440.    ULONG Mode;                      /* see definitions below */
  441.    ULONG Triggers;                  /* see definitions below */
  442.    union {
  443.       struct {                      /* for SEND_SIGNAL */
  444.          struct Task *Task;
  445.          ULONG SignalNum;
  446.       } Signal;
  447.  
  448.       struct {                      /* for SEND_MESSAGE */
  449.          struct MsgPort *Port;
  450.       } Message;
  451.    };
  452.  
  453.    /* NOTE: This structure may be extended in future! */
  454. };
  455.  
  456.    /*
  457.     *    Monitor Modes
  458.     */
  459.  
  460. #define muMon_IGNORE       (0)
  461. #define muMon_SEND_SIGNAL  (1)
  462. #define muMon_SEND_MESSAGE (2)
  463.  
  464.    /*
  465.     *    Monitor Message
  466.     *
  467.     *
  468.     *    Sent to the application if SEND_MESSAGE is specified.
  469.     *    Do NOT forget to reply!
  470.     */
  471.  
  472. struct muMonMsg {
  473.    struct Message ExecMsg;
  474.    struct muMonitor *Monitor;       /* The monitor that sent the message */
  475.    ULONG Trigger;                   /* The trigger that caused the message */
  476.    UWORD From;
  477.    UWORD To;
  478.    char UserID[muUSERIDSIZE];
  479. };
  480.  
  481.    /*
  482.     *    Monitor Triggers
  483.     */
  484.  
  485. #define muTrgB_OwnerChange       (0)   /* Task Owner Change */
  486.                                        /*    From:    uid of old user */
  487.                                        /*    To:      uid of new user */
  488. #define muTrgB_Login             (1)   /* successful Login/Logout */
  489.                                        /*    From:    uid of old user */
  490.                                        /*    To:      uid of new user */
  491.                                        /*    UserID:  UserID of new user */
  492. #define muTrgB_LoginFail         (2)   /* unsuccessful Login/Logout */
  493.                                        /*    From:    uid of old user */
  494.                                        /*    UserID:  UserID of new user */
  495. #define muTrgB_Passwd            (3)   /* successful Passwd */
  496.                                        /*    From:    uid of user */
  497. #define muTrgB_PasswdFail        (4)   /* unsuccessful Passwd */
  498.                                        /*    From:    uid of user */
  499. #define muTrgB_CheckPasswd       (5)   /* successful CheckPasswd */
  500.                                        /*    From:    uid of user */
  501. #define muTrgB_CheckPasswdFail   (6)   /* unsuccessful CheckPasswd */
  502.                                        /*    From:    uid of user */
  503.  
  504. #define muTrgF_OwnerChange       (1<<muTrgB_OwnerChange)
  505. #define muTrgF_Login             (1<<muTrgB_Login)
  506. #define muTrgF_LoginFail         (1<<muTrgB_LoginFail)
  507. #define muTrgF_Passwd            (1<<muTrgB_Passwd)
  508. #define muTrgF_PasswdFail        (1<<muTrgB_PasswdFail)
  509. #define muTrgF_CheckPasswd       (1<<muTrgB_CheckPasswd)
  510. #define muTrgF_CheckPasswdFail   (1<<muTrgB_CheckPasswdFail)
  511.  
  512.  
  513. #endif  /* LIBRARIES_MULTIUSER_H */
  514.